<template>
  <div class="list-table">
    <el-table v-loading="loading" :data="fundFundFpSourceList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('回款来源')" align="center" prop="hkSource" min-width="180" show-overflow-tooltip />
      <el-table-column :label="$t('分配现金') + $t('金额单位')" align="center" prop="fpCash" min-width="180">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.fpCash, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('分配成本') + $t('金额单位')" align="center" prop="fpCost" min-width="180">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.fpCost, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('分配收益') + $t('金额单位')" align="center" prop="fpProfit" min-width="180">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.fpProfit, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('GP Carry') + $t('金额单位')" align="center" prop="gpCarry" min-width="180">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.gpCarry, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('LP合计') + $t('金额单位')" prop="lpTotal" align="center" min-width="180">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.lpTotal, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('GP合计') + $t('金额单位')" prop="gpTotal" align="center" min-width="180">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.gpTotal, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('操作')" fixed="right" align="center" class-name="small-padding fixed-width" width="140">
        <template slot-scope="scope">
          <div>
            <el-button
              size="small"
              type="text"
              icon="el-icon-s-order"
              @click="fundInvestorFpDetailsHandle(scope.row)"
            >{{ $t('出资人分配明细') }}</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 基金费用明细 -->
    <el-dialog :title="title" :visible.sync="listOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm" append-to-body>
      <fundInvestorFpDetailsList ref="fundInvestorFpDetailsList" />
    </el-dialog>
  </div>
</template>

<script>
import { findFundFpSourceList } from '@/api/fund/fp/fundFpSource'
import fundInvestorFpDetailsList from '@/views/fund/fp/fundInvestorFpDetailsList'
export default {
  components: {
    fundInvestorFpDetailsList
  },
  data() {
      return {
          // 遮罩层
          loading: true,
          // 总条数
          total: 0,
          // 基金费用明细表格数据
        fundFundFpSourceList: [],
          // 弹出层标题
          title: '基金费用明细',
          // 是否显示弹出层
          listOpen: false,
          investorsTypeOptions: [],
          // 查询参数
          queryParams: {
              fpId: undefined,
              pageNum: 1,
              pageSize: 10
          },
          // 表单参数
          form: {},
          // 表单校验
          rules: {}
      }
  },
  created() {
  },
  methods: {
    /** 查询基金费用明细列表 */
    getList() {
        this.loading = true
      findFundFpSourceList(this.queryParams).then(response => {
              this.fundFundFpSourceList = response.rows
              this.total = response.total
              this.loading = false
        })
    },
    getFundFpSourceList(row) {
      this.loading = true
      this.queryParams.fpId = row.id
      findFundFpSourceList(this.queryParams).then(response => {
        this.fundFundFpSourceList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 基金收益明细 */
    fundInvestorFpDetailsHandle(row) {
      this.listOpen = true
      this.title = this.$t('出资人分配明细')
      this.$nextTick(() => {
        // 调用List页面的 getfundInvestorFpDetails 方法初始化数据
        this.$refs.fundInvestorFpDetailsList.getfundInvestorFpDetails(row)
      })
    },
    // 表单重置
    reset() {
        this.form = {
          id: undefined,
          fundId: undefined,
          fpId: undefined,
          incomeId: undefined,
          dealId: undefined,
          dataSource: undefined,
          fundIncome: undefined,
          hkSource: null,
          fpCash: null,
          fpCost: null,
          fpProfit: null,
          gpCarry: undefined,
          lpTotal: undefined,
          gpTotal: undefined,
          remark: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined
        }
        this.resetForm('form')
    }
  }
}
</script>
